<template>
    <view>
        <j-cell-group>
            <j-cell title="时间" :tips="time" @jftap="onBindtapTime"></j-cell>
            <j-cell title="日期" :tips="week" @jftap="onBindtapWeek"></j-cell>
        </j-cell-group>
    </view>
</template>

<script>
export default {
    data() {
        return {
            formatWeektoString: getApp().globalData.utils.formatWeektoString,
            parseCron: getApp().globalData.utils.parseCron,
            time: '',
            week: []
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {
        console.log('=== scene:condition-timer:onLoad:');
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        console.log('=== scene:condition-timer:onReady:');
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        console.log('=== scene:condition-timer:onShow:');
        let conditionList = uni.getStorageSync('scene').conditionList; // getApp().globalData.scene.conditionList

        let fields = this.parseCron(conditionList);
        let dayOfWeek = fields.dayOfWeek;
        let hour = fields.hour;
        let minute = fields.minute;
        this.time = hour + ':' + (minute <= 9 ? '0' + minute : minute)
        this.week = this.formatWeektoString(dayOfWeek)
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
        console.log('--- scene:condition-timer:onHide:');
    },
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
        console.log('--- scene:condition-timer:onUnload:');
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    methods: {
        onBindtapTime(ev) {
            uni.navigateTo({
                url: '/jvss/pagesScene/condition-timer-time/condition-timer-time'
            });
        },

        onBindtapWeek(ev) {
            uni.navigateTo({
                url: '/jvss/pagesScene/condition-timer-week/condition-timer-week'
            });
        }
    }
};
</script>
<style>
.picker {
    display: flex;
    justify-content: space-between;
    background: #ffffff;
    margin: 20rpx;
    padding: 20rpx;
}
</style>
